<template>
  <div class="banner-card" @click="onClick">
    <div class="bg-img" v-if="image" :style="{backgroundImage: bgImage}">
      <div class="title">{{title}}</div>
      <div class="sub-title">{{subTitle}}</div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'BannerCard',
    props: {
      title: String,
      subTitle: String,
      image: {type: String, default: null}
    },
    computed: {
      bgImage () {
        return 'url(' + this.image + ')'
      }
    },

    methods: {
      onClick () {
        this.$emit('onClick')
      }
    }
  }
</script>

<style scoped lang="scss">
  .banner-card {
    margin-top: 20px;
    padding: 0 20px;
    box-sizing: border-box;
    .bg-img {
      background: aquamarine;
      width: 100%;
      height: 120px;
      border-radius: 10px;
      background-size: 100% 100%;
      background-repeat: no-repeat;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .title {
        font-size: 20px;
        font-weight: 500;
        color: #fff;
      }
      .sub-title {
        width: fit-content;
        padding: 5px 15px;
        background: brown;
        border: 1px solid #ccc;
        border-radius: 50px;
        margin-top: 12px;
        font-size: 15px;
        font-weight: 500;
        color: #fff;
      }
    }
  }
</style>
